﻿@using Kendo.Mvc.UI
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>@ViewBag.Title || Telerik Connect</title>
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <meta name="viewport" content="width=device-width" />
    @Styles.Render("~/Content/css")
    <link href="~/Content/styles/kendo.common.min.css" type="text/css" rel="stylesheet" />
    <link href="~/Content/styles/kendo.metro.min.css" type="text/css" rel="stylesheet" />
    @Scripts.Render("~/bundles/jquery")
    <script src="~/Scripts/kendo.all.min.js" type="text/javascript"></script>
    <script src="~/Scripts/kendo.aspnetmvc.min.js" type="text/javascript"></script>
    @Scripts.Render("~/bundles/modernizr")
    @RenderSection("scripts", required: false)
</head>
<body>
    <div id="main-wrapper">
        <header>
            <div class="content-wrapper clear-fix">
                <div class="float-left">
                    <p class="site-title">@Html.ActionLink("your logo here", "Index", "Home")</p>
                </div>
                <div class="float-right">
                    <nav>
                        <ul id="Menu">
                            @if (Request.IsAuthenticated)
                            {
                                <li>@Html.ActionLink("Home", "Index", "Home")</li>
                                <li>@Html.ActionLink("Manage Users", "Index", "Admin")</li>
                            }
                            else
                            {
                                <li>@Html.ActionLink("Login", "Login", "Account")</li>
                            }
                            <li>@Html.ActionLink("About", "About", "Home")</li>
                            @if (Request.IsAuthenticated)
                            {
                                <li><a href="/Account/Profile/@User.Identity.Name" id="menu-profile"><span id="menu-username">@User.Identity.Name</span></a>
                                    <ul>
                                        <li>
                                            <span id="menu-messages">Messages</span>
                                            <ul>
                                                <li>
                                                    <a id="menu-inbox" href="~/Messages/Inbox">Inbox</a>
                                                </li>
                                                <li>
                                                    <a href="~/Messages/Sent">Sent</a>
                                                </li>
                                                <li>
                                                    <span id="compose-message">Compose</span>
                                                </li>
                                            </ul>
                                        </li>
                                        <li><a href="~/Account/Edit">Edit Profile</a></li>
                                        <li>
                                            @using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" }))
                                            {
                                                @Html.AntiForgeryToken()

                                                //<input type="submit" value="Log Out" />
                                            }
                                            <a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>
                                        </li>
                                    </ul>
                                </li>
                            }
                            else
                            {
                                <li>@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li>
                            }
                        </ul>
                    </nav>
                </div>
            </div>
        </header>

        <div id="body">
            @RenderSection("featured", required: false)
            <section class="content-wrapper main-content clear-fix">
                @RenderBody()
            </section>
        </div>

        <footer id="footer">
            <div>
                <div>
                    <p>&copy; @DateTime.Now.Year - Antony Jekov</p>
                </div>
            </div>
        </footer>
    </div>
    @(Html.Kendo().Window()
    .Name("window")
    .Title("")
    .Draggable()
    .Resizable()
    .Visible(false)
    .Width(480)
    )

    <script>
        $("#Menu").kendoMenu();

        $("#compose-message").click(function () {
            var data = '<iframe frameborder = "0" width="480" height="300" src="/Messages/Send" ></iframe>';
            var kendoWindow = $("#window").data("kendoWindow");
            kendoWindow.content(data);

            kendoWindow.center();
            kendoWindow.open();
        });

        $(function () {

            $.ajax({
                url: ('@Url.Content("~/Messages/UnreadMessagesCount")'),
                dataType: "text",
                success: function (result) {
                    if (result != "0") {
                        $("#menu-username").append(" <span class='warrning'>(" + result + ")</span>");
                        $("#menu-messages").append(" <span class='warrning'>(" + result + ")</span>");
                        $("#menu-inbox").append(" <span class='warrning'>(" + result + ")</span>");
                    }
                }
            });
        })
    </script>
</body>
</html>
